<?php namespace system\database\seeds;
use houdunwang\database\build\Seeder;
use houdunwang\db\Db;
use system\model\Category;
class CategoryTableSeeder extends Seeder {
    //执行
    public function up() {
        //Db::table('news')->insert(['title'=>'后盾人']);
        $data = [
            [ 'cate_name'        => '男装' ,
                'cate_description' => '男装' ,
                'cate_sort'        => 1 ,
                'cate_linkurl'     => 'http://www.houdunwang.=>com' ,
                'cate_pid'         => 0,
            ] ,
            [ 'cate_name'        => '风衣' ,
                'cate_description' => '风衣' ,
                'cate_sort'        => 1 ,
                'cate_linkurl'     => 'http://www.houdunwang.=>com' ,
                'cate_pid'         => 1,
            ] ,
            [ 'cate_name'        => '大衣' ,
                'cate_description' => '大衣' ,
                'cate_sort'        => 1 ,
                'cate_linkurl'     => 'http://www.houdunwang.=>com' ,
                'cate_pid'         => 1,
            ] ,
            [ 'cate_name'        => '男鞋' ,
                'cate_description' => '男鞋' ,
                'cate_sort'        => 1 ,
                'cate_linkurl'     => 'http://www.houdunwang.=>com' ,
                'cate_pid'         => 0,
            ] ,
            [ 'cate_name'        => '豆豆鞋' ,
                'cate_description' => '豆豆鞋' ,
                'cate_sort'        => 1 ,
                'cate_linkurl'     => 'http://www.houdunwang.=>com' ,
                'cate_pid'         => 4,
            ] ,
            [ 'cate_name'        => '布鞋' ,
                'cate_description' => '布鞋' ,
                'cate_sort'        => 1 ,
                'cate_linkurl'     => 'http://www.houdunwang.=>com' ,
                'cate_pid'         => 4,
            ] ,
        ];
        //循环遍历数据
        foreach ( $data as $k => $v ) {
            $category = new Category();
            //Category模型
            //允许填充的字段['*'],$timestamps=true
            $category->save($v);
        }
    }
    //回滚
    public function down() {
        Schema::truncate('category');
    }
}